/////////////////////////////////////////////////////////////////////
//	$file: $
//	$revision: $
//	$author: $
//	$datetime: $
//	first author: buggy

#ifndef	__SourceNavigator_h__
#define	__SourceNavigator_h__

#include	<QWidget>


class	QVBoxLayout;
class	SourceTree;
class	SourceTreeItem;
class	StatusBar;

///////////////////////////////////////////////////////////
//	Source Navigator Widget
class	SourceNavigator	:	public	QWidget
{
public:
	SourceNavigator(const QString& rootPath);
	virtual	~SourceNavigator();

	bool		IsNavigationMode()	const	{	return _modeNav;	}
	QString		SerachText()		const	{	return _searchText;	}
	bool		IsValid()			const;
	QString		RootName()			const;
	QString		RootPath()			const;

	void		OpenTextEditor(const SourceTreeItem* src, int startPosition = 0);
	void		CloseTextEditor(const SourceTreeItem* src);
	void		SaveTextEditorFile(const SourceTreeItem* src);
	void		MoveTextEditorWindow(const SourceTreeItem* src, int posIndex);

	void		CloseAllTextEditors();
	void		SaveTextEditorAllFiles();

	void		ExecuteShell(const QString& shellCommand = "");

	void		BeginCommandInput(QString command);
	void		CancelCommandInput();

	void		UpdateSearch(const QString& search);

	void		TransitMode(QKeyEvent* event);
	void		ForwardKeyEventToCommand(QKeyEvent* event);
	void		ForwardKeyEventToNavigation(QKeyEvent* event);

private:
	void		closeFiles(SourceTreeItem* src);
	void		saveFiles(SourceTreeItem* src);
	void		doCommand(const QString& command);
	void		doSearch();

private:
	bool				_modeNav;
	QString				_searchText;
	QVBoxLayout*		_layout;
	SourceTree*			_tree;
	StatusBar*			_bar;
};


#endif	//	__SourceNavigator_h__
